#include "HttpServer.hpp"

void Useage(const string& exe){
    LOG(LogLevel::ERROR) << "please use" << exe <<"+ port";
}

void Login(const Request& req,Response& rsp){
    LOG(LogLevel::INFO) << "请求资源路径: " << req.Path() << " 请求参数" << req.Args();
    rsp.SetCode(200);
    rsp.SetBody(rsp.GetContent("wwwroot/success.html"));
    rsp.SetSuffix("wwwroot/success.html");
}

int main(int argc,char* argv[]){
    if(argc != 2){
        Useage(argv[0]);        
        exit(1);
    }
    uint16_t port = stoi(argv[1]);
    HttpServer server(port);
    server.InsertPath("/login",Login);
    server.Init();
    server.Start();
}